//
//  MassLossVC.m
//  CJRailTransport
//
//  Created by Hank on 2017/12/21.
//  Copyright © 2017年 amplity. All rights reserved.
//

#import "MassLossVC.h"
#import "MassLossCell.h"
#import "BreakageVC.h"
#import "SendRepairVC.h"
#import "ReceiveVC.h"
#import "RepairVC.h"

@interface MassLossVC ()
// 列表数据
@property (strong ,nonatomic)NSArray *dataArray;

@end

@implementation MassLossVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // 设置导航栏
    [self setNavC];
    // 设置界面属性
    [self setViewAttribute];
    // 设置数据
    [self setData];
    // 注册Cell
    [self registerCells];
}

#pragma mark - 导航栏
- (void)setNavC
{
    self.title = @"质损";
    // 设置导航栏颜色
    BasicNavigationController *nVC = (BasicNavigationController *)self.navigationController;
    nVC.themeColor = [UIColor whiteColor];
    nVC.tintColor = [UIColor darkGrayColor];
}

// 设置界面属性
- (void)setViewAttribute
{
    self.view.backgroundColor = [UIColor whiteColor];
}

// 注册Cell
- (void)registerCells
{
    UINib *nib = [UINib nibWithNibName:[MassLossCell reuseIdentifier] bundle:nil];
    [_myTableView registerNib:nib forCellReuseIdentifier:[MassLossCell reuseIdentifier]];
}

// 设置数据
- (void)setData
{
    self.dataArray = @[@"质损", @"送修", @"接收", @"维修"];
}

#pragma mark - TableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MassLossCell *cell = [tableView dequeueReusableCellWithIdentifier:[MassLossCell reuseIdentifier] forIndexPath:indexPath];
    cell.indexPath = indexPath;
    [cell setData:_dataArray[indexPath.row]];
    return cell;
}
#pragma mark - TableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 根据数据类型进行判断
    switch (indexPath.row) {
        case 0:{
            // 质损
            BreakageVC *breakageVC = [[BreakageVC alloc]init];
            [self.navigationController pushViewController:breakageVC animated:YES];
            break;
        }
        case 1:{
            // 送修
            SendRepairVC *sendRepairVC = [[SendRepairVC alloc]init];
            [self.navigationController pushViewController:sendRepairVC animated:YES];
            break;
        }
        case 2:{
            // 接收
            ReceiveVC *receiveVC = [[ReceiveVC alloc]init];
            [self.navigationController pushViewController:receiveVC animated:YES];
            break;
        }
        case 3:{
            // 维修
            RepairVC *repairVC = [[RepairVC alloc]init];
            [self.navigationController pushViewController:repairVC animated:YES];
            break;
        }
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
